/*
 * @Descripttion: 用于配置vue-router相关
 * @version: 
 * @@Company: None
 * @Author: 孤鹜
 * @Date: 2022-01-27 08:33:26
 * @LastEditors: 孤鹜
 * @LastEditTime: 2022-01-27 16:19:48
 */
import VueRouter from "vue-router";
import Vue from "vue";

Vue.use(VueRouter)

const routes = [
  {
    path: '/test',
    component: () => import('../components/drawer.vue'),
    meta: {
      title: '测试使用'
    }
  }
]

const router = new VueRouter({
  routes,
  mode: 'history'
})

// 全局导航守卫，在页面跳转之前更改页面的title
router.beforeEach((to, from, next) => {
  if(to.meta.title) {
    document.title = to.matched[0].meta.title
  }
  next()
})

export default router